package com.awspaas.user.apps.shhtaerospaceindustrial.guaranteecar;


	import java.util.List;
import java.util.Map;

import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.InterruptListener;
import com.actionsoft.bpms.bpmn.engine.listener.InterruptListenerInterface;
import com.actionsoft.bpms.commons.database.ColumnMapRowMapper;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.exception.BPMNError;
import com.actionsoft.sdk.local.SDK;
import com.awspaas.user.apps.shhtaerospaceindustrial.util.CoreUtil;

	public class checkDispatchIsnotWrite extends InterruptListener  implements InterruptListenerInterface{

		public String getDescription() {
			return "调度派单时，检验“派出车辆牌号”、“派出驾驶员”是否填写！";
		}
		
		public String getProvider() {
			return "Actionsoft";
		}
		
		public String getVersion() {
			return "1.0";
		}
		
		@Override
		public boolean execute(ProcessExecutionContext param) throws Exception {
			boolean flag_ok = SDK.getTaskAPI().isChoiceActionMenu(param.getTaskInstance(), "派单");
			if(flag_ok) {
				// 记录ID
				String processInstId = param.getProcessInstance().getId();
				//根据流程实例ID获取任务表内数据
				List<Map<String , Object>> list = DBSql.query("SELECT *  FROM BO_EU_GUARANTEECAR  "
						+ "WHERE BINDID = ? ", new ColumnMapRowMapper(), new Object[] {processInstId});
				Map<String , Object>  datarecord = list.get(0);
				String LICENSENUM =CoreUtil.objToStr(datarecord.get("LICENSENUM"));// 派出车辆牌号
				String DRIVER =CoreUtil.objToStr(datarecord.get("DRIVER"));// 派出驾驶员
				if ("".equals(LICENSENUM)) {
					
					throw new BPMNError("“派出车辆牌号”不能为空，请填写后才能提交！");
					
				} else if("".equals(DRIVER)) {
					throw new BPMNError("“派出驾驶员”不能为空，请填写后才能提交！");
				}
			}
			return true;
		}

	}
